#!/usr/bin/env python
# -*- coding:utf8 -*-

"""
@version: 
@author: lh
@license: Apache Licence 
@contact: liuhuan0672@gmail.com
@site: 
@software: PyCharm
@file: 0009.py
@time: 2016/1/20 16:35

第 0009 题：一个HTML文件，找出里面的链接。

"""
import re
import urllib.request


def find_links(website):
    html_content = urllib.request.urlopen(website).read()
    r = re.compile('href="(.*?)"')
    result = r.findall(html_content.decode('utf-8'))
    return result
    # html_content = urllib.request.urlopen(website).read()
    # r = re.compile('href="(.*?)"')
    # result = r.findall(html_content.decode('utf-8'))
    # return result


if __name__ == '__main__':
    for i in find_links("http://www.zhihu.com/"):
        print(i)
